<template>
  <div class="mod-menu">
    <el-form :inline="true" :model="dataForm">
      <el-form-item>
        <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
      </el-form-item>
    </el-form>

    <el-table
      :data="dataList"
      row-key="menuId"
      border
      style="width: 100%; ">
      <el-table-column
        prop="id"
        align="center"
        header-align="center"
        label="ID" >
      </el-table-column>
      <el-table-column
        prop="nickName"
        header-align="center"
        align="center"
        label="用户昵称" >
      </el-table-column>
      <el-table-column
        prop="status"
        header-align="center"
        :formatter="getStatus"
        align="center"
        label="状态">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row)">冻结</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 弹窗, 新增 / 修改 -->
  </div>
</template>

<script>
export default {
  data () {
    return {
      addVisible: false,
      dialogVisible: false,
      dataForm: '',
      disabled: false,
      dialogImageUrl: '',
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      searchItem: {}
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    getList () {
      this.$http({
        url: this.$http.adornUrl('/wx_user/page?page=' + this.pageIndex + '&size=' + this.pageSize),
        method: 'post',
        data: this.$http.adornData(this.searchItem)
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataList = data.page.list
          this.totalPage = data.page.totalCount
        } else {
          this.dataList = []
          this.totalPage = 0
        }
      })
    },
    addOrUpdateHandle (row) {
      this.$http({
        url: this.$http.adornUrl('/wx_user/changeStatus?id=' + row.id),
        method: 'get',
        data: {}
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.visible = false
            }
          })
        }
        this.getList()
        this.editVisible = false
      })
    },
    getStatus (row) {
      if (row.status === 0) {
        return '未冻结'
      } else {
        return '已冻结'
      }
    }
  }
}
</script>

<style scoped>

</style>
